import xadmin
from .models import Secene, Outline, SeceneDescType, Comment, SeceneMarkDesc, SeceneGroup


class OutlineAdmin(object):
    model_icon = 'fa fa-book'
    list_display = ['name', 'sort_order', 'add_time']
    search_fields = ['name', 'add_time', 'sort_order']
    list_filter = ['add_time', 'sort_order']

    ordering = ['-add_time']

    # readonly_fields 和 exclude 的字段不要重复，否则会冲突
    readonly_fields = ['add_time']


class SeceneAdmin(object):
    model_icon = 'fa fa-anchor'
    list_display = ['title', 'description', 'add_time']
    search_fields = ['title', 'add_time']
    list_filter = ['add_time', ]
    style_fields = {'description': 'ueditor'}

    ordering = ['-add_time']

    # readonly_fields 和 exclude 的字段不要重复，否则会冲突
    readonly_fields = ['add_time']


class SeceneDescTypeAdmin(object):
    model_icon = 'fa fa-bookmark-o'
    list_display = ['name', 'description']
    search_fields = ['name', 'description']
    list_filter = ['name', ]

    ordering = ['name']


class CommentAdmin(object):
    model_icon = 'fa fa-comments'
    list_display = ['add_time', 'content']
    search_fields = ['add_time', ]

    ordering = ['-add_time']


class SeceneMarkDescAdmin(object):
    model_icon = 'fa fa-map-marker'
    list_display = ['add_time', 'content']
    search_fields = ['add_time', ]

    ordering = ['-add_time']


class SeceneGroupAdmin(object):
    model_icon = 'fa fa-map-marker'
    list_display = ['name']
    search_fields = ['name', ]


xadmin.site.register(Outline, OutlineAdmin)
xadmin.site.register(Secene, SeceneAdmin)
xadmin.site.register(SeceneDescType, SeceneDescTypeAdmin)
xadmin.site.register(Comment, CommentAdmin)
xadmin.site.register(SeceneMarkDesc, SeceneMarkDescAdmin)
xadmin.site.register(SeceneGroup, SeceneGroupAdmin)
